<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>mainWindow</title>
</head>

<body>
    <h1>主窗口</h1>
    <h3>通过window.open(...)打开另一个隔壁窗口：</h3>
    <button id="openNew">打开隔壁窗口</button>
    <h3>通过window.open(...)的返回值改变隔壁窗口背景</h3>
    <button id="turnRed">变红</button>
    <button id="turnOrange">变橙</button>
    <button id="turnYellow">变黄</button>

    <script type="text/javascript" src="../../source/jquery-3.2.1.min.js"></script>

    <script>
    var $openNew = $('#openNew');
    var anotherWindow = null;
    $openNew.on('click', function() {
        anotherWindow = window.open('http://sluggish.gitee.io/staticpages/tab-communication/window-opener/otherWindow.html');
    });
    $('#turnRed').on('click', function() {
        anotherWindow.document.bgColor = 'red';
    });
    $('#turnOrange').on('click', function() {
        anotherWindow.document.bgColor = 'orange';
    });
    $('#turnYellow').on('click', function() {
        anotherWindow.document.bgColor = 'yellow';
    });
    </script>
</body>

</html>